Skip to content

feat(ssr-client-hints): nested cookie config for color scheme#367

Merged
AndreyYolkin merged 6 commits into
mainfrom
feat/344-cookie-domain
Jun 8, 2026
Merged

feat(ssr-client-hints): nested cookie config for color scheme#367
AndreyYolkin merged 6 commits into
mainfrom
feat/344-cookie-domain

Conversation

@AndreyYolkin

@AndreyYolkin AndreyYolkin commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Reshapes the color-scheme cookie configuration under prefersColorSchemeOptions into a nested cookie: {} object and adds control over Secure/SameSite.

  • New prefersColorSchemeOptions.cookie?: { name?, domain?, secure?, sameSite? }.
  • cookieName is kept but deprecated (maps to cookie.name; emits one build-time warning when used). When both are set, cookie.name wins.
  • The previously proposed flat cookieDomain option is removed — use cookie.domain.
  • secure and sameSite were previously hardcoded (SameSite=Lax, no Secure); they are now configurable. secure is forced to true when sameSite is 'none'.

Default behaviour is unchanged: cookie.name defaults to color-scheme, SameSite=Lax, no Secure, no Domain.

ssrClientHints: {
  prefersColorScheme: true,
  prefersColorSchemeOptions: {
    cookie: {
      name: 'color-scheme',
      domain: '.example.com',
      sameSite: 'lax',
      // secure: true,
    },
  },
}

Implementation notes

  • Public input gains the nested cookie object; the resolved/runtime config stays flat (cookieName, cookieDomain, cookieSecure, cookieSameSite) to keep the runtime plugins simple.
  • Normalisation (legacy + nested → flat) lives in prepareSSRClientHints, extracted into a small resolveColorSchemeCookie helper.

Test Plan

  • Unit tests for prepareSSRClientHints normalisation: nested-only, legacy-only (warns), both (new wins), defaults, sameSite:'none' forces secure.
  • Full unit suite (32 tests) passing.
  • Lint clean; module + playground typecheck (dev:prepare) clean.

@AndreyYolkin AndreyYolkin changed the title feat(ssr-client-hints): add optional cookieDomain configuration feat(ssr-client-hints): nested cookie config for color scheme Jun 8, 2026
@AndreyYolkin AndreyYolkin merged commit 2f68da1 into main Jun 8, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant